#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
#include <sstream>
#include <list>
#include <stack>
#include <queue>
#include <map>
using namespace std;

struct ListNode {
     int val;
     ListNode *next;
     ListNode() : val(0), next(nullptr) {}
     ListNode(int x) : val(x), next(nullptr) {}
     ListNode(int x, ListNode *next) : val(x), next(next) {}
};
//打印链表
void displayList(ListNode *p){
    while( p ){
        cout<< p->val ;
        p = p->next;
        if(p) cout<<"->";
    }
    cout<<endl;
}


//解决方案类
class Solution {
public:
    bool validMountainArray(vector<int>& A) {
        int len = A.size(), st = 0, tmp = A[0];
        if (len < 3 ) return false;
        for(int i = 1;i<len;i++){
            if(st == 0 ) {
                if( A[i] > tmp ) tmp = A[i],st = 1 ;
                else return false;
            } else if(st == 1) {
                if( A[i] > tmp ) tmp = A[i] ;
                else if( A[i] == tmp ) return false;
                else tmp = A[i],st = 2;
            } else {
                if( A[i] < tmp ) tmp = A[i] ;
                else  return false;
            }
        }
        return st == 2 ;
    }

    bool validMountainArray2(vector<int>& A) {
        int len = A.size() ,  g = 1;
        if (len < 3 ) return false;
        for(;g<len && A[g] > A[g-1];g++);
        if( g==1 || g == len )return false;
        for(;g<len && A[g] < A[g-1] ; ++g);
        return g == len ;
    }
};
int main(){
    Solution sp;
    vector<int> a = {1,2,3};
    bool c = sp.validMountainArray2(a);
    cout << c << endl;
    return 0;
}